layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

    form.on("submit(editRoleBase)", function (data) {
        //弹出loading
        var index = top.layer.msg('数据保存中，请稍候...', {icon: 16, time: false, shade: 0.8});
        $.post("/role/base/edit", data.field, function (res) {
            if (res.data) {
                var _index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(_index);
                layer.close(index);
                parent.location.reload();
                layer.msg("保存成功！");
            } else {
                layer.close(index);
                layer.msg(res.msg);
            }
        });
        layer.close(index);
        return false;
    });

    $(".cancel").click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
        parent.location.reload();
    })
});